import java.util.Scanner;

// 银行卡
public class Card {
    private int cardNumber;
    private String password;
    private double sal;
    // alt + insert -> 快捷生成getter/setter

    // getter
    public int getCardNumber() {
        return cardNumber;
    }
    // getter
    public String getPassword() {
        return password;
    }
    // getter
    public double getSal(String pass) {
        if (pass.equals(password)) {
            return sal;
        }else {
            System.out.println("密码错误，请查证后再试");
        }
        return -1.0;
    }
    // setter
    public void setPassword(String pass) {
        if (pass == password) {
            System.out.println("输入正确，可以修改密码");
            // 请输入新密码
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入新密码:");
            String newPassword = scanner.next();
            password = newPassword;
        }else {
            System.err.println("密码不正确，无法修改");
        }
    }
}

